import {Component, OnInit} from 'angular2/core';
import {TreeNodeComponent} from './tree-node.component/index';
import {TreeData} from './tree-data';
import {DragNDropService} from './drag_n_drop.service';
import {TreeViewService} from './treeview.service';

@Component({
  selector: 'tree-view',
  // moduleId: module.id,
  templateUrl: 'app/treeview.component.html',
  styleUrls: [],
  inputs: ['treeData'],
  directives: [TreeNodeComponent],
  providers: [DragNDropService]
})
export class TreeViewComponent implements OnInit {
  public treeData: TreeData;
  selectedNode: TreeData;

  constructor(private _service: TreeViewService) {
  }

  ngOnInit() {
    console.log('sub data', this._service);
    this._service.treeData.subscribe(treeData => {
      this.treeData = treeData;
    });
  }
}